package com.itboye.ihomebank.responsitory;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.ihomebank.adapter.BiaoQianBean;
import com.itboye.ihomebank.base.BaseNetRepository;
import com.itboye.ihomebank.base.ICompleteListener;
import com.itboye.ihomebank.bean.ChanKanWeiXiuBean;
import com.itboye.ihomebank.bean.HouseBean;
import com.itboye.ihomebank.bean.WeixiuXinxiBean;
import com.itboye.ihomebank.interfaces.IRepairInterface;
import com.itboye.ihomebank.net.BaseErrorListener;
import com.itboye.ihomebank.net.BaseSuccessReqListener;
import com.itboye.ihomebank.net.ByJsonRequest.Builder;

/***
 * 请求网络类
 * 
 * @author admin
 * 
 */
public class RepairRepository extends BaseNetRepository implements
		IRepairInterface<HouseBean> {
	String api = "100";
	String shenQingWeiXiu="BY_Repair_addapply";//申请维修
	
	String weixiuLeixing="BY_Repair_show";//申请维修
	
	String weiXiuZhuangTai="BY_Repair_look";//查看维修状态
	String yiDao="BY_Repair_arrive";//师傅已到
	
	String theEnd="BY_Repair_endapply";//维修结束
	String theEndAndPingJia="BY_Repair_evaluate";//维修结束并评价
	String biaoqian="BY_Repair_findtags";//查看师傅评价标签

	public RepairRepository(ICompleteListener iCompleteListener) {
		super(iCompleteListener);
	}

	@Override
	public void shenQingWeiXiu(String uid,String image, String uname, String umobile,
			String repairId,String repairStatus, String ill, String address, String community,
			String status, String id) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("uname", uname);
		map.put("umobile", umobile);
		map.put("repair_id", repairId);
		map.put("repair_status", repairStatus);
		map.put("ill", ill);
		map.put("address", address);
		map.put("community", community);
		map.put("status", status);
		map.put("id", id);
		map.put("image", image);
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(shenQingWeiXiu, apiVer,
						map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}
	/**
	 * 查看维修信息(用来返回报修类型)
	 */
	@Override
	public void weiXiuXinXi(String status) {
		Type type = new TypeToken<WeixiuXinxiBean>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("status", status);
		(new Builder<WeixiuXinxiBean>())
				.setTypeVerParamsAndReturnClass(weixiuLeixing, apiVer,
						map, type)
				.requestListener(
						new BaseSuccessReqListener<WeixiuXinxiBean>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
		
	}
	/**
	 * 查看维修状态
	 */
	@Override
	public void chanKanWeiXiu(String uid, String status) {
		Type type = new TypeToken<List<ChanKanWeiXiuBean>>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("status", status);
		(new Builder<List<ChanKanWeiXiuBean>>())
				.setTypeVerParamsAndReturnClass(weiXiuZhuangTai, apiVer,
						map, type)
				.requestListener(
						new BaseSuccessReqListener<List<ChanKanWeiXiuBean>>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
		
	}
	/**
	 * 师傅已到
	 */
	@Override
	public void shiFuYiDao(String pid) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("pid", pid);
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(yiDao, apiVer,
						map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
		
	}
	/**
	 * 维修结束
	 */
	@Override
	public void xiuLiEnd(String pid) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("pid", pid);
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(theEnd, apiVer,
						map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
		
	}
	/**
	 * 维修结束并评价
	 */
	@Override
	public void xiuLiEndAndPingJia(String pid, int evaluate, String tags) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("pid", pid);
		map.put("evaluate", evaluate);
		map.put("tags", tags);
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(theEndAndPingJia, apiVer,
						map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
		
	}
	/**
	 * 查看师傅评价标签
	 */
	@Override
	public void biaoQian() {
		Type type = new TypeToken<List<BiaoQianBean>>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		(new Builder<List<BiaoQianBean>>())
				.setTypeVerParamsAndReturnClass(biaoqian, apiVer,
						map, type)
				.requestListener(
						new BaseSuccessReqListener<List<BiaoQianBean>>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
		
	}

	
}
